package com.vcredit.creditcat.web.app;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.IApplyStrategyManager;
import com.vcredit.creditcat.dto.ApplyStragyDto;
import com.vcredit.creditcat.model.ApplyStrategy;
import com.vcredit.creditcat.vo.ApplyStrategyRetunVo;
import com.vcredit.creditcat.vo.ApplyStrategyVo;
import com.vcredit.creditcat.vo.JsonResult;
import com.vcredit.framework.annotation.Log;
import com.vcredit.framework.util.BeanUtil;

@RestController
@RequestMapping("/applyStrategy")
public class ApplyStrategyController extends BaseCreditCatController {

	@Reference(version = "1.0")
	private IApplyStrategyManager iApplyStrategyManager;

	@Log
	@RequestMapping("/answer")
	public JsonResult<ApplyStrategyVo> reportAnalysis(@RequestBody ApplyStragyDto applyStragyDto,
			HttpServletRequest request) throws Exception {
		ApplyStrategyVo applyStrategyVo = new ApplyStrategyVo();
		List<ApplyStrategy> vo = iApplyStrategyManager.answer(applyStragyDto.getProductId());
		List<ApplyStrategyRetunVo> vos = BeanUtil.copy(vo, ApplyStrategyRetunVo.class);
		applyStrategyVo.setApplyStrategy(vos);
		return JsonResult.SuccessResponse(applyStrategyVo);
	}
}
